// Add window.onkeyup with trashing an existing function.
function addOnKeyUp(handler) {
  var currentHandler = window.onkeyup;
  if (typeof currentHandler == 'function') {
    window.onkeyup = function(e) {
      currentHandler(e);
      handler(e);
    };
  } else {
    window.onkeyup = handler;
  }
}

var handler = function(e) {
  // return if no modifiers.
  if (!e.shiftKey || !e.ctrlKey) {
    return;
  }
  // Only send if we are interested.
  switch (e.keyCode) {
    // Pgup/dn
    case 33:
    case 34:
    // 0..9
    case 48:
    case 49:
    case 50:
    case 51:
    case 52:
    case 53:
    case 54:
    case 55:
    case 56:
    case 57:
      chrome.extension.sendRequest(
        {keyCode: e.keyCode},
        function(response) {
          // No-op.
        });
     break;
  }
};
if (navigator.appVersion.indexOf("Linux") < 0) {
  addOnKeyUp(handler);
}
